/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import com.sun.lwuit.Command;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.layouts.BoxLayout;
import core.ScreenEngine;
import view.additional.CellItem;
import view.additional.MenuList;
import view.commands.BackCommand;

/**
 *
 * @author Kvest
 */
public class ViewEditForm extends BasicForm implements MenuList.MenuListSelection
{
    public static final int OK_COMMAND_ID = 0;
    
    private static final int FONT_EDIT_ID = 0;
    
    private MenuList items;
    
    private FontEditForm fontEditForm;
    
    public ViewEditForm()
    {
        super("edit_view");
                
        init();
    }
    
    private void init()
    {
        setLayout(new BoxLayout(BoxLayout.Y_AXIS));
        setScrollable(false);

        //Заполняем меню
        items = new MenuList();
        items.addItem(new CellItem(FONT_EDIT_ID ,"font_edit"));
        items.setSelectionListener(this);
        addComponent(items);
        
        //Команды
        addCommand(new BackCommand());
        
        Command ok = new Command("ok", OK_COMMAND_ID)
        {
            public void actionPerformed(ActionEvent evt)
            {
                itemSelected(items.getSelectedId());
                
                evt.consume();
            }
        };
        addCommand(ok);
    }
    
    public void itemSelected(int id)
    {
        switch(id)
        {
            case FONT_EDIT_ID : showFontEditForm(); break;
        }
    }
    
    private void showFontEditForm()
    {
        if (fontEditForm == null)
        {
            fontEditForm = new FontEditForm();
        }
        
        ScreenEngine.getEngine().push(fontEditForm);
    }
}
